// 1. 引入异步对象
import request from "@/utils/request"

// 引入约束
import type {AttrInfoModel,AttrListModel,AttrValueInfoModel} from './model/attrModel'
import type { CategoryIdsModel } from "./model/categoryModel"

// 2. 使用枚举存储接口地址
enum Api {
  // 获取属性列表的Api
  getAttrListApi = "/admin/product/attrInfoList",
  // 删除属性的API
  deleteAttrApi = "/admin/product/deleteAttr",
  // 添加或跟新属性的API
  saveAttrApi='admin/product/saveAttrInfo'
}

// 3. 书写接口函数
/*
 *根据三级导航Id获取书写列表的接口函数
 */
 export const reqGetAttrListData = ({category1Id,category2Id,category3Id}:CategoryIdsModel) => {
  return request.get<any,AttrListModel>(Api.getAttrListApi+`/${category1Id}/${category2Id}/${category3Id}`)
 }
/**
 * 封装了一个删除属性的接口函数
 * @param attrId
 * @returns 
 */
 export const reqDeleteOneAttr = (attrId:number)=>{
  return request.delete<any,null>(Api.deleteAttrApi+`/${attrId}`)
 }

 export const reqAddOrUpdateAttrInfo = (attrInfo:AttrInfoModel)=>{
  return request.post<any,null>(Api.saveAttrApi,attrInfo)
 }